﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
using System.Diagnostics;
using Mengsk.ERP.Phone;
using System.Windows.Threading;

namespace Mengsk.ERP.App
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        public static string UserName { get; private set; }


        public static void DoEvents()
        {
            Application.Current.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
        }


        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            try
            {
                Login l = new Login();
                bool? ret = l.ShowDialog();
                if (ret == null || ret == false)
                {
                    return;
                }
                UserName = l.UserName;
                new MainWindow().ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                this.Shutdown();
            }
        }
    }
}
